package com.english.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * 班级签到记录表
 *
 * @author wlq
 * @since 2025-08-08
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("attendance")
public class ClassAttendance implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 学生ID
     */
    @TableField("student_id")
    private Long studentId;

    /**
     * 班级ID
     */
    @TableField("class_id")
    private Long classId;

    /**
     * 签到日期
     */
    @TableField("attendance_date")
    private LocalDate attendanceDate;

    /**
     * 课程时间
     */
    @TableField("class_time")
    private LocalTime classTime;

    /**
     * 签到时间
     */
    @TableField("sign_in_time")
    private LocalDateTime signInTime;

    /**
     * 签退时间
     */
    @TableField("sign_out_time")
    private LocalDateTime signOutTime;

    /**
     * 状态：SIGNED_IN=已签到, SIGNED_OUT=已签退, ABSENT=缺勤
     */
    @TableField("status")
    private AttendanceStatus status;

    /**
     * 备注
     */
    @TableField("notes")
    private String notes;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField("update_time")
    private LocalDateTime updateTime;

    // 关联信息（非数据库字段）
    @TableField(exist = false)
    private String studentName;

    @TableField(exist = false)
    private String className;

    @TableField(exist = false)
    private String adminName;

    /**
     * 签到状态枚举
     */
    public enum AttendanceStatus {
        SIGNED_IN("已签到"),
        SIGNED_OUT("已签退"),
        ABSENT("缺勤");

        private final String description;

        AttendanceStatus(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }
} 